﻿using Caliburn.Micro;
using KouDai.Phone.Engine;
using KouDai.Phone.Helper;
using KouDai.Phone.Models;
using KouDai.Phone.Services;
using KouDai.Phone.Utils;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;

namespace KouDai.Phone.ViewModels
{
    public class PhotoListBoxPageViewModel : KouDaiScreen
    {
        #region Fields
        private INavigationService _navigationService;
        private ObservableCollection<HoneyEntity> _honeyItems = new ObservableCollection<HoneyEntity>();
        #endregion

        #region Constructor

        public PhotoListBoxPageViewModel()
        {
            if (Execute.InDesignMode)
            {
                LoadDesignData();
            }
        }

        public PhotoListBoxPageViewModel(INavigationService navigationService)
        {
            _navigationService = navigationService;
        }
        #endregion

        #region Properties
        public ObservableCollection<HoneyEntity> HoneyItems
        {
            get { return _honeyItems; }
            set
            {
                if (value != _honeyItems)
                {
                    _honeyItems = value;
                    this.NotifyOfPropertyChange(() => this.HoneyItems);
                }
            }
        }
        #endregion

        #region Override

        public override void LoadDesignData()
        {
            List<HoneyEntity> honeyList = new List<HoneyEntity>();
            for (int i = 0; i < 10; i++)
            {
                honeyList.Add(new HoneyEntity { ImageUrlForIphone = "http://img.geilicdn.com/taobao18553835260_146x146.jpg", Name = "2013新款韩版甜美淑女毛毛包夹子包毛绒绒手拿斜挎单肩女包包" });
            }
            honeyList.ToObservableCollection(HoneyItems);
        }

        protected override async void OnInitialize()
        {
            BackData backData = await ServiceManager.GetImageWall("Combine_Default", 0);
            if (backData.IsSuccess)
            {
                List<HoneyEntity> honeyList = (List<HoneyEntity>)backData.ResposeData;
                honeyList.ToObservableCollection(HoneyItems);
            }
            else
            {
                Debug.WriteLine("获取数据失败--->");
            }
          
        }

        protected override void OnViewAttached(object view, object context)
        {
            base.OnViewAttached(view, context);
        }

        protected override void OnViewLoaded(object view)
        {
            base.OnViewLoaded(view);
        }

        protected override void OnActivate()
        {
            base.OnActivate();
        }

        protected override void OnDeactivate(bool close)
        {
            base.OnDeactivate(close);
        }

        protected override void OnViewReady(object view)
        {
            base.OnViewReady(view);
        }

        #endregion

        #region Method
        
        #endregion
    }
}
